<template>
    <view class="content">
        <view class="title text-lg">订单信息</view>
        <view class="box text-noraml u-p-b-30">
            <view class="item">
                <view>订单号</view>
                <view class="item-r text-bold" v-if="type == 1">{{ data.order_no}}</view>
                <view class="item-r text-bold" v-if="type == 2">{{ data.purchases}}</view>
                <view class="item-r text-bold" v-if="type == 3">{{ data.belong }}</view>
            </view>
            <view class="item">
                <view>下单时间</view>
                <view class="item-r text-bold" v-if="type == 1">{{ data.create_time}}</view>
                <view class="item-r text-bold" v-if="type == 2">{{ data.create_time}}</view>
                <view class="item-r text-bold" v-if="type == 3">{{ data.belong_time }}</view>
            </view>
            
            <view class="item" v-if="type == 2">
                <view>供货单位</view>
                <view class="item-r text-bold">{{data.supplier}}</view>
            </view>
            <view class="item" v-else>
                <view>{{ data.type == 1 ? '购货企业' : '供货单位' }}</view>
                <view class="item-r text-bold">{{data.shop}}</view>
            </view>
            
            <view class="item" v-if="type == 2">
                <view>销售人员</view>
                <view class="item-r text-bold">{{data.salesman}}</view>
            </view>
            <view class="item" v-else>
                <view>{{ data.type == 1 ? '采购人员' : '销售人员' }}</view>
                <view class="item-r text-bold">{{data.buyer}}</view>
            </view>
            
            <view class="item" v-if="data.put_address">
                <view>收货地址</view>
                <view class="item-r text-bold">{{data.put_address}}</view>
            </view>
            <view class="item" v-if="data.receiver">
                <view>收货人员</view>
                <view class="item-r text-bold">{{data.receiver}}</view>
            </view>
            <view class="item">
                <view>是否冷链</view>
                <view class="item-r text-bold">{{ data.is_freeze == 1 ? '是' : '否' }}</view>
            </view>
            <view class="place text-df text-gray" v-if="type == 3">
                <view class="u-p-t-15">领单人：{{data.draw_member}}</view>
                <view class="u-p-t-15">领单时间：{{data.draw_time}}</view>
            </view>
        </view>
        
        <view class="title text-lg">订单物品</view>
        <view class="wrapper">
            <view class="drug text-df text-gray" v-for="(item, index) in data.goods_list" :key="index">
                <view class="u-flex">
                    <view class="u-flex-1">物品名称：{{item.goods_name}}</view>
                </view>
                <view class="u-p-t-15" v-if="item.dosage">剂型：{{item.dosage}}</view>
                <view class="u-p-t-15" v-if="item.batch">批次号：{{item.batch}}</view>
                <view class="u-p-t-15" v-if="item.goods_spec">规格：{{item.goods_spec}}</view>
                <view class="u-p-t-15" v-if="item.period_date">有效日期：{{item.period_date}}</view>
                <view class="u-p-t-15" v-if="item.factory">生产厂家：{{item.factory}}</view>
                <view class="u-p-t-15" v-if="item.supplier">供货厂家：{{item.supplier}}</view>
                <view class="u-p-t-15" v-if="item.stock_nums">库存量：{{item.stock_nums}}</view>
                <view class="u-p-t-15" v-if="item.buy_nums || item.goods_nums">
                    订单数量：{{ type == 3 ? item.buy_nums : item.goods_nums }}
                </view>
                <view class="u-p-t-15" v-if="item.sale_price">单价（元）：￥{{item.sale_price}}</view>
                <view class="u-p-t-15" v-if="item.goods_amount">总价（元）：￥{{item.goods_amount}}</view>
                <view class="u-p-t-15" v-if="item.stores_house">库区：{{item.stores_house}}</view>
                <view class="u-p-t-15" v-if="item.library">货位：{{item.library}}</view>
                <view class="down" v-if="item.tray">
                    <view class="u-flex-1">托盘：{{item.tray}}</view>
                </view>
            </view>
        </view>
        
        <view class="btn-square u-m-30" v-if="type != 3" @click="$noMultipleClicks(doNeck)">领单</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                noClick: true,//连点
                id: '',
                type: '',
                data: {},
            };
        },
        onLoad(option) {
            this.id = option.id
            this.type = option.type
            this.getData()
        },
        methods: {
            // 领单
            doNeck() {
                this.$ajax('inventory_out/draw', {
                    userToken: this.$getSync('userToken'),
                    order_id: this.id,
                    type: this.type,
                }).then(ret => {
                	if (ret.status == 0) {
                        this.$toast('领单成功')
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.message);
                	}
                });
            },
            
            getData() {
                let url = '', param = {}
                if (this.type == 3) {
                    // 已领取 待出库
                    url = 'inventory_out/out_detail'
                    param = {
                        userToken: this.$getSync('userToken'),
                        id: this.id,
                    }
                } else {
                    // 待领取
                    url = 'inventory_out/unclaimed_detail'
                    param = {
                        userToken: this.$getSync('userToken'),
                        id: this.id,
                        type: this.type, //1-订单  2-采购售后
                    }
                }
            	this.$ajax(url, param).then(ret => {
            		if (ret.status == 0) {
                        this.data = ret.data
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    .down{
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding-top: 15rpx;
    }
    .drug-btn{
        color: #fff;
        padding: 10rpx 30rpx;
        background-color: #8392a5;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    
    page{
        background-color: #f5f5f5 !important;
    }
    .title{
        font-weight: bold;
        padding: 45rpx 50rpx 25rpx;
        position: relative;
    }
    .title::after{
        display: block;
        content: '';
        width: 8rpx;
        height: 26rpx;
        background-color: #ff4800;
        position: absolute;
        left: 25rpx;
        bottom: 32rpx;
    }
    
    
    .box{
        padding: 0 30rpx;
        background-color: #fff;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        border-bottom: 2rpx solid #e6e6e6;
    }
    .item:last-child{
        border-bottom: none;
    }
    .item-r{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
        text-align: right;
        padding-left: 20rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .item-img{
        padding: 30rpx 0;
    }
    .img{
        width: 316rpx;
        height: 200rpx;
        border-radius: 10rpx;
        margin-top: 20rpx;
    }
    
    
    .drug{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 35rpx 30rpx;
        margin-bottom: 25rpx;
        word-break: break-all;
        white-space: pre-line;
    }
    .drug:last-child{
        margin-bottom: 0;
    }
    .drug-state1{
        font-size: 24rpx;
        color: #0075ff;
        padding: 9rpx 12rpx;
        background-color: #ebf4fe;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    .drug-state2{
        font-size: 24rpx;
        color: #00c28f;
        padding: 9rpx 12rpx;
        background-color: #e9fbf6;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    
    .examine{
        word-break: break-all;
        white-space: pre-line;
        padding: 15rpx 25rpx 30rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin: 0 30rpx 25rpx;
    }
    .t-inp{
        width: 100%;
        min-height: 150rpx;
        height: auto;
        padding-top: 15rpx;
    }
    .examine2{
        padding: 15rpx 0;
    }
    .img-box{
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .up-photo{
        width: 187rpx;
        height: 187rpx;
        margin-right: 15rpx;
        margin-top: 15rpx;
    }
    
    
    .btns{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 30rpx;
    }
    .refuse-btn{
        font-size: 34rpx;
        color: #757575;
        padding: 25rpx 130rpx;
        background-color: #fff;
        border: 2rpx solid #d8d8d8;
        border-radius: 10rpx;
    }
    .take-btn{
        font-size: 34rpx;
        color: #fff;
        padding: 25rpx 130rpx;
        background-color: #ff4800;
        border-radius: 10rpx;
        margin-left: 20rpx;
    }
    
    .enter-btn{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-top: 10rpx;
    }
    .enter-btn>view{
        padding: 15rpx 50rpx;
        background-color: #8392a5;
        border-radius: 10rpx;
        color: #fff;
    }
    
    .place{
        word-break: break-all;
        white-space: pre-line;
        padding: 5rpx 20rpx 20rpx;
        background-color: #f5f6f8;
        border-radius: 10rpx;
        margin-top: 30rpx;
    }
    .wrapper{
        padding: 0 30rpx;
    }
    .choose-01{
        width: 33rpx;
        height: 33rpx;
        margin-right: 15rpx;
    }
    .time-02{
        width: 33rpx;
        height: 34rpx;
        margin-left: 15rpx;
    }

</style>
